<template>
  <div>
    <div class="box" @click=" addLishi(seaitem),$router.push({ path: '/xiangqing', query: { id: (seaitem?.r?.id||seaitem?.note?.id||seaitem?.r?.vc) } }) ">
      <div class="left">
        <van-image
          width="100rem"
          height="90rem"
          fit="cover"
          
          :src="seaitem.r?.img||seaitem.r?.p"
        />
      </div>
      <div class="right">
        <h1>{{ seaitem.r?.n||seaitem.r?.tips }}</h1>
        <div class="xingrong">{{ seaitem.r?.cookstory }}</div>
        <div class="hz">
          <p>{{ seaitem.r?.recommendation_tag }}</p>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import Vue from "vue";
import { Image as VanImage } from "vant";

Vue.use(VanImage);
export default {
  props: ["seaitem"],
  data() {
    return {
      itemts: JSON.parse(window.localStorage.getItem("itemts")) || [],
    }
  },
  computed: {
    isCollection: function () {
      const arr =
        this.itemts.filter((o) => {
          return o.ckid === this.itemts.id;
        }) || [];
      return arr.length > 0 ? true : false;
    },
  },
  methods: {
    addLishi(seaitem) {
      // console.log(seaitem.r.id);
      this.cookid = seaitem.r.id;
      // console.log("cookid", this.cookid);
      this.itemts = [{ ckid: `${this.cookid}` }, ...this.itemts];
      window.localStorage.setItem("itemts", JSON.stringify(this.itemts));
    },
  },
};
</script>

<style lang="scss" scoped>
.van-image{
  img{
    width: 100%;
    height: 100%;
    display: block;
    object-fit: cover;
  }
}
.box{
  display: flex;
  .right{
    height: 100rem;
    position: relative;
    h1{
      font-size: 16rem;
      font-weight: 700;
      margin: 15rem 0 0 10rem;
      color: #777;
    }
    .xingrong{
      // height: 30rem;
      width: 230rem;
      margin: 5rem 0 0 10rem;
      font-size: 12rem;
      overflow: hidden;
      -webkit-line-clamp:3;
      display:-webkit-box; 
      -webkit-box-orient:vertical;
    }
    .hz{
      position: absolute;
      bottom: 10rem;
      left: 10rem;
    }
  }
}
</style>
